<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      var ary = [
        {
          id: 1,
          name: "66",
        },
        {
          id: 2,
          name: "77",
        },
      ];
      let target = ary.find((item) => item.id == 2);
      // 在数组中找到属性id 值为2的那个对象 返回值是这个对象  找到了就会终止循环
      // console.log(target);
      let arr = [
        {
          id: 1,
          num: 1,
        },
        {
          id: 3,
          num: 3,
        },
      ];
      let result = arr.find((value) => value.id == 3);
      console.log(result); // 找到就返回该对象
    </script>
  </body>
</html>
